package ClassesAndObjects;

class Students {
    private String name;
    private int age;

    //静态成员变量
    private static String classRoom ;

    //静态代码块，用来初始化静态成员变量的初始值
    static {
        classRoom = "302";
        System.out.println("静态代码块！");

    }

    public Students() {
        System.out.println("调用了不带参数的构造方法！");
    }

    public Students(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("调用了带2个参数的构造方法！");
    }

    {
        //一般用来为对象的成员的初始化
        //this.name = "zhangsan";
        System.out.println("构造快！");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void print() {
        System.out.println("姓名:" +name + " 年龄:"+age);
    }
}

public class Test3 {
    public static void main(String[] args) {
        Students student1 = new Students("lisi", 10);
        student1.print();
        System.out.println("========");
        //Students student2 = new Students();
    }
}
